package com.rpc.netty.core.protocol;

import com.alibaba.fastjson.JSON;

/**
 * @author david
 */
public class FastJsonSerializer implements Serializer {
    public static final FastJsonSerializer INSTANCE = new FastJsonSerializer();

    @Override
    public <T> byte[] serialize(T obj) {
        return JSON.toJSONBytes(obj);
    }

    @Override
    public <T> T deserialize(byte[] data, Class<T> cls) {
        return JSON.parseObject(data, cls);
    }
}
